<?php
class SendInviteMail extends PageBase{
	var $email;
	var $url;
	var $name;
	var $groupId;
	public function __construct($tpl,$param){
		parent::__construct($tpl);
		$this->email = $param['email'];
		$this->url = $param['url'];
		$this->name = $param['name'];
		$this->groupId = $param['groupId'];
	}
	function Ini(){
		$info = $this->db->fetchOne("SELECT * FROM biz_group WHERE group_id=".intval($this->groupId));
		$this->assign('content',replaceImg(replaceHtml($info['content'])));
		$this->assign('name',$this->name);
		$this->assign('url',$this->url);
		$this->assign('title',$info['title']);
	}
	function send(){
		global $EmailConfig;
		$mail = new PHPMailer();
		$mail->IsSMTP();                                   // send via SMTP
		$mail->Host     = $EmailConfig['SmtpServer']; // SMTP servers
		$mail->SMTPAuth = true;     // turn on SMTP authentication
		$mail->Username = $EmailConfig['user'];  // SMTP username
		$mail->Password = $EmailConfig['pwd']; // SMTP password
		
		$mail->From     = $EmailConfig['EmailAccount'];
		$mail->FromName = $EmailConfig['NickName'];
		$mail->AddAddress($this->email,$this->userInfo['seller_name']); 
		//$mail->AddAddress("ellen@site.com");               // optional name
		$mail->AddReplyTo($EmailConfig['EmailAccount'],$EmailConfig['NickName']);
		
		$mail->WordWrap = 50;                              // set word wrap
		//$mail->AddAttachment("/var/tmp/file.tar.gz");      // attachment
		//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); 
		$mail->IsHTML(true);                               // send as HTML
		
		$mail->Subject  =  "=?UTF-8?B?" . base64_encode("酷店--邀请朋友") . "?=";
		$mail->Body     =  $this->fetch();
		$mail->CharSet = 'UTF-8';
		
		return $mail->Send();
	}
}
?>